/*
* pps_bom
*/
package com.pitop.bom.service;

import com.pitop.bom.api.BomLogFeignApi;
import com.pitop.bom.entity.BomLog;
import com.pitop.core.entity.Page;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.exceptions.BomLogException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * bom日志
 *
 * @author berton
 */
@Service("bomLogSVImpl")
@Slf4j
public class BomLogSVImpl {

    @Autowired
    private BomLogFeignApi bomLogFeignApi;

    /**
     * 加载一个对象BomLog
     *
     * @param id
     * @return BomLog
     */
    public BomLog load(Long id) {
        if (id == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomLogFeignApi.load(id);
    }

    /**
     * 加载一个对象BomLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return BomLog
     */
    public BomLog loadById(Long id) {
        if (id == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomLogFeignApi.loadById(id);
    }

    /**
     * 加载一个对象BomLog,(将查询关联数据)
     *
     * @param id
     * @return BomLog
     */
    public BomLog get(Long id) {
        if (id == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomLogFeignApi.get(id);
    }

    /**
     * 加载一个对象BomLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return BomLog
     */
    public BomLog getById(Long id) {
        if (id == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return bomLogFeignApi.getById(id);
    }

    /**
     * 删除对象BomLog
     *
     * @param id
     */

    public void delete(Long id) {
        if (id == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        bomLogFeignApi.delete(id);
    }

    /**
     * 查询BomLog分页
     *
     * @param bomLog   对象
     * @param curPage  当前页
     * @param pageSize 分页条数
     * @return List<BomLog>
     */
    public List<BomLog> list(BomLog bomLog, int curPage, int pageSize) {
        return bomLogFeignApi.list(bomLog, curPage, pageSize);
    }

    /**
     * 查询BomLog分页
     *
     * @param id
     * @param curPage  当前页
     * @param pageSize 分页条数
     * @return List<BomLog>
     */
    public List<BomLog> list(Long id, int curPage, int pageSize) {
        if (curPage < 0) {
            curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        BomLog bomLog = new BomLog();
        bomLog.setId(id);

        return bomLogFeignApi.list(bomLog, curPage, pageSize);
    }

    public int count(Long id) {
        return bomLogFeignApi.count(id);
    }

    public int count(BomLog bomLog) {
        return bomLogFeignApi.count(bomLog);
    }

    /**
     * 保存
     *
     * @param bomLog 实体
     * @throws BaseException
     */
    public void save(BomLog bomLog) {
        if (bomLog == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        bomLogFeignApi.build(bomLog);
    }

    /**
     * 更新
     *
     * @param bomLog 实体
     * @throws BaseException
     */
    public void modify(BomLog bomLog) {
        if (bomLog == null) {
            throw new BomLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        bomLogFeignApi.modify(bomLog);
    }
}
